require("should");

var sample1 = require('../lib/sample1');

describe("sample1 单元测试",function(){
    before(function(){
        console.log("单元测试开始了");
    });
    beforeEach(function(){
        console.log("another unit test start");
    });
    describe("fibonacci 函数的单元测试",function(){
        it("fibonacci(10) should  == 55",function(){
           var actual =  sample1.fibonacci(10);
           actual.should.equal(55);
        });
        it("fibonacci(0) should  == 0",function(){

           var actual =  sample1.fibonacci(0);
           actual.should.equal(0);
        });
        it("fibonacci(1) should  == 1",function(){

           var actual =  sample1.fibonacci(1);
           actual.should.equal(1);
        });
        it("fibonacci(-1) should throw error",function(){
            (function(){
                sample1.fibonacci(-1);
            }).should.throw('n必须大于0');
        });

        it("fibonacci(11) should throw error",function(){
            (function(){
                sample1.fibonacci(11);
            }).should.throw('n必须小于等于10');
        });

        it("fibonacci(呵呵) should throw error",function(){
            (function(){
                sample1.fibonacci('呵呵');
            }).should.throw('n必须是个数字');
        });
    });
    
    afterEach(function(){
        console.log("another unit test end");
    });
    after(function(){
        console.log("单元测试结束了");
    });


});